package com.question.java.time.exec08;

import java.time.LocalDate;
import java.time.Month;
import java.time.Period;

/**
 * @Description: 例子：计算当天到2020年美国选举日(11月3号)的天数
 * 通过Period类实现
 * @Author: Jun Yang
 */
public class DateTimeExample41 {
    public static void main(String[] args) {
        LocalDate selectionDay = LocalDate.of(2020, Month.NOVEMBER, 3);
        LocalDate today = LocalDate.now();
        Period until = today.until(selectionDay);
        final int years = until.getYears();
        final int months = until.getMonths();
        final int days = until.getDays();
        System.out.printf("%d years, %d months, %d days to go...", years, months, days);
    }
}
